package com.swipemaster.elements;

import javax.microedition.khronos.opengles.GL10;

import com.swipemaster.common.Coords;
import com.swipemaster.moves.Move;

/**
 * A class describing primitive elements appearing on the screen.
 */
public class Element
{
	protected Coords coords;
	protected Move move;
	protected int color;
	
	public Element()
	{
	}
	
	public Element(Coords coords, Move move, int color)
	{
		this.coords = coords;
		this.move = move;
		this.color = color;
	}

	/**
	 * Called periodically in order to move element.
	 */
	public void move()
	{
		coords = move.getNextCoords(coords);
	}

	/**
	 * Should be abstract, but Gson has problems with polymorphism.
	 * 
	 * @return True, if there is a collision between this and given element.
	 */
	public boolean isCollisionWith(Element element)
	{
		throw new RuntimeException("You can't call abtract methods.");
	}

	/**
	 * Should be abstract, but Gson has problems with polymorphism.
	 * 
	 * Draws element on the screen using OpenGL.
	 */
	public void draw(GL10 gl)
	{
		throw new RuntimeException("You can't call abtract methods.");
	}
	
	public void setCoords(Coords coords)
	{
		this.coords = coords;
	}
}
